<template>
    <div class="newsinfo-container">
        <h3 class="title">{{newsinfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间:{{newsinfo.add_time | dateFormat}}</span>
            <span>点击：{{newsinfo.click}}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsinfo.content">

        </div>
        <!-- 评论的子组件 -->
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
import Comment from '../subcomponent/Comment.vue'
export default {
    data(){
        return {
            id:this.$route.params.id,
            newsinfo:null
        }
    },
    created(){
        this.getNewsInfo();
    },
    methods:{
        getNewsInfo(){
            this.$http.get("news/info/"+this.id).then(
                response => {
                    if (response.body.status === 0) {
                        this.newsinfo = response.body.message; 
                    }
                }
            );
        }
    },
    components:{
        "commentBox":Comment
    }
}
</script>
    
<style lang="scss" scoped>
    .newsinfo-container {
        padding: 0 5px;
        .title {
            font-size: 16px;
            margin: 12px 0;
            text-align: center;
            color: #f00;
        }
        .subtitle {
            font-size: 13px;
            color: #22afea;
            display: flex;
            justify-content: space-between;
        }
    }
</style>
